extends Node2D

# 基础游戏脚本
var score = 0
var game_running = true

@onready var score_label = $UI/ScoreLabel

func _ready():
	print("坦克大战游戏启动！")
	update_ui()

func update_ui():
	if score_label:
		score_label.text = "分数: " + str(score)

func _input(event):
	if not game_running:
		return
		
	if event is InputEventKey and event.pressed:
		match event.keycode:
			KEY_SPACE:
				# 射击
				score += 10
				update_ui()
				print("射击！分数: " + str(score))
			KEY_R:
				# 重新开始
				restart_game()
			KEY_ESCAPE:
				# 退出游戏
				get_tree().quit()

func restart_game():
	score = 0
	game_running = true
	update_ui()
	print("游戏重新开始！")
